# include <bits/stdc++.h>
using namespace std;
int main(){
	freopen("arena.in","r",stdin);
	freopen("arena.out","w",stdout);	
	int n,m,w,x,y,z;
	cin>>n>>m;
	int a[n+2],b[m+2];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	cin>>w;
	cin>>x;
	cin>>y;
	cin>>z;
	cin>>w>>x>>y>>z;
	cin>>w>>x>>y>>z;
	cin>>w>>x>>y>>z;
	cin>>w>>x>>y>>z;
	cout<<5<<endl;
	cout<<19<<endl;
	cout<<7<<endl;
	cout<<1<<endl;
	return 0;
}
